import { configureStore } from '@reduxjs/toolkit';
import { combineReducers } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage'; // 使用 localStorage 作为默认存储
import demoSlice from '@/reducers/demo';
import mainSlice from '@/reducers/main';

const persistConfig = {
  key: 'root',
  storage,
};
const rootReducer = combineReducers({
    demo: demoSlice,
    main: mainSlice,
  });
const persistedReducer = persistReducer(persistConfig, rootReducer);

const store = configureStore({
  reducer: persistedReducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: false,
    }),
});

const persistor = persistStore(store);

export { store, persistor };

